<template>
	<my-main title="发票申请详情" isBg  :isDep="false" isBack @infoFun="infoFun">
		<view class="orderDetails">
			<my-cell title="基本信息" isBox>
				<my-text label="单据单号" :value="formData?.InvoiceRequestCode" :labelWidth="labelWidth" />
				<my-text label="单据状态" :value="formData?.StatusName === '草稿' ? '待确认' : formData?.StatusName" :labelWidth="labelWidth" />
				<my-text label="创建时间" :value="formData?.BillingDate" :labelWidth="labelWidth" />
				<my-text label="创建人" :value="formData?.InvoiceApplicant" :labelWidth="labelWidth" />
				<my-text label="开票对象" :value="formData?.InvoiceObject" :labelWidth="labelWidth" />
				<my-text label="审核人" :value="formData?.AuditObject" :labelWidth="labelWidth" />
				<my-text label="开票人" :value="formData?.InvoiceEnter" :labelWidth="labelWidth" />
			</my-cell>
			<my-cell title="单据信息" isBox>
				<my-text label="开票客户" :value="formData?.ClientName" :labelWidth="labelWidth" />
				<my-text label="关联对账" :value="formData?.DZDCode" :labelWidth="labelWidth" />
			</my-cell>
			<my-cell title="购买方信息" isBox>
				<my-text label="企业抬头" :value="formData?.InvoiceHead" :labelWidth="labelWidth" />
				<my-text label="企业税号" :value="formData?.InvoiceTaxCode" :labelWidth="labelWidth" />
				<my-text label="企业地址" :value="formData?.InvoiceAddress" :labelWidth="labelWidth" />
				<my-text label="企业电话" :value="formData?.InvoiceTel" :labelWidth="labelWidth" />
				<my-text label="开户银行" :value="formData?.BankName" :labelWidth="labelWidth" />
				<my-text label="开户账号" :value="formData?.BankCode" :labelWidth="labelWidth" />
			</my-cell>
			<my-cell title="销售方信息" isBox>
				<my-text label="企业抬头" :value="formData?.InvoiceSalerId" :labelWidth="labelWidth" />
				<my-text label="企业税号" :value="formData?.SellTaxNo" :labelWidth="labelWidth" />
				<my-text label="企业地址" :value="formData?.SellAddress" :labelWidth="labelWidth" />
				<my-text label="企业电话" :value="formData?.SellTel" :labelWidth="labelWidth" />
				<my-text label="开户银行" :value="formData?.SellerBankName" :labelWidth="labelWidth" />
				<my-text label="开户账号" :value="formData?.SellerBankCode" :labelWidth="labelWidth" />
			</my-cell>
			<my-cell title="发票信息" isBox>
				<my-text label="开票类型" :value="formData?.InvoiceType" :labelWidth="labelWidth" />
				<my-text label="开票金额" :value="`￥${formData?.BillTotalAmt || 0}`" :labelWidth="labelWidth" />
				<my-text label="发票号码" :value="formData?.InvoiceCode" :labelWidth="labelWidth" />
			</my-cell>
			<my-cell title="发票备注" isBox>
				<view class="f-24">
					<up-parse :content="formData?.InvoiceRemark" v-if="formData.InvoiceRemark"></up-parse>
					<text v-else class="text-color-text">无备注</text>
				</view>
			</my-cell>
			<my-cell title="发票明细项" isBox>
				<my-list :options="formData.invoiceDetails">
					<template #item="{ row }">
						<view class="f-28 bg-color-bg p-16 radius-8">
							<view class="f-32 fwb">{{ `	*${row.TaxName || '--'}*${row.CustTaxName || '--'}` }}</view>
							<view class="m-t-16 text-color-text flex-2">
								<view class="flex-item">{{ `规格型号：${row.Model || '--'}` }}</view>
								<view class="flex-item">{{ `单位：${row.Unit || '--'}` }}</view>
								<view class="flex-item">{{ `数量：${row.Number || '--'}` }}</view>
								<view class="flex-item">{{ `单价：${row.UnitPrice || 0}` }}</view>
							</view>
							<view class="flex bg-color-white m-t-12 p-16 radius-8">
								<view class="flexAuto flex-c-start-center">
									<view class="countTitle">金额</view>
									<view class="countNumber">{{ row.TotalPrice }}</view>
								</view>
								<view class="line"></view>
								<view class="flexAuto flex-c-start-center">
									<view class="countTitle">税率/征收率</view>
									<view class="countNumber">{{ `${row.TaxRate * 100}%` }}</view>
								</view>
								<view class="line"></view>
								<view class="flexAuto flex-c-start-center">
									<view class="countTitle">数额</view>
									<view class="countNumber">{{ row.TaxAmount }}</view>
								</view>
							</view>
						</view>
					</template>
				</my-list>
			</my-cell>
			<my-cell title="订单单据明细" isBox v-if="['订单', '储值卡'].includes(formData?.InvoiceObject)">
				<my-list :options="formData.orderDetails" v-if="formData?.InvoiceObject === '订单'">
					<template #item="{ row }">
						<view class="f-28 bg-color-bg p-16 radius-8">
							<view class="f-32 fwb">{{ `${row.OrderName || '--'}` }}</view>
							<view class="m-t-8 text-color-text">
								<view>{{ `单据单号：${row.OrderCode || '--'}` }}</view>
							</view>
							<view class="flex bg-color-white m-t-12 p-16 radius-8">
								<view class="flexAuto flex-c-start-center">
									<view class="countTitle">单据金额</view>
									<view class="countNumber">{{ row.OrderAmt }}</view>
								</view>
								<view class="line"></view>
								<view class="flexAuto flex-c-start-center">
									<view class="countTitle">开票金额</view>
									<view class="countNumber">{{ row.DoneInvoiceAmt }}</view>
								</view>
							</view>
						</view>
					</template>
				</my-list>
				<my-list :options="formData.skdDetails" v-else>
					<template #item="{ row }">
						<view class="f-28 bg-color-bg p-16 radius-8">
							<view class="m-t-8 text-color-text">
								<view>{{ `单据单号：${row.SkdCode || '--'}` }}</view>
							</view>
							<view class="flex bg-color-white m-t-12 p-16 radius-8">
								<view class="flexAuto flex-c-start-center">
									<view class="countTitle">单据金额</view>
									<view class="countNumber">{{ row.BillingAmt }}</view>
								</view>
								<view class="line"></view>
								<view class="flexAuto flex-c-start-center">
									<view class="countTitle">开票金额</view>
									<view class="countNumber">{{ row.DoneInvoiceAmt }}</view>
								</view>
							</view>
						</view>
					</template>
				</my-list>
			</my-cell>
		</view>
	</my-main>
</template>

<script lang="uts" setup>
//公共状态
import { useVue  } from '@/utils/useVue.uts'
const { reactive, ref,app,Token,onMounted,watch,http,goToPage,formatDate,getTimeAgo,proxy,getDaysUntilDeadline } = useVue()
interface Props {
	id?:string,
}
const props = withDefaults(defineProps<Props>(), {

})
const labelWidth=ref(160)
// 表单数据
const formData:any = ref({
	Address:[],
	Files:[],
	Goods:[],
	Header:{},
	OtherFees:[],
	Payments:[],
	SelfAddress:[],
	financial:{},
	logs:[],
})
const options=reactive({

})

const getDetails = () => {
	http.request({
			url: 'api/FinancialMan/AppInvoiceDetail',
			data:{
				Id:props.id,
			},
			success: (res : any) => {
				formData.value=res
			},
			fail:()=>{

			}
		})
}

//初始运行
const infoFun = () => {
	getDetails()
}
onMounted(() => {

})
</script>

<style scoped lang="scss">
.class-name {
	font-weight: bold;
}
</style>
